package pw.hais.etgsh.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;

import java.util.ArrayList;
import java.util.List;

import pw.hais.app.UtilConfig;
import pw.hais.etgsh.R;
import pw.hais.etgsh.activity.ArticleListActivity;
import pw.hais.etgsh.adapter.GuShiTypeAdapter;
import pw.hais.etgsh.app.BaseFragment;
import pw.hais.etgsh.model.GuShiTypeModel;

/**
 * 故事
 * Created by hais1992 on 2016/1/23/023.
 */
public class GuShiFragment extends BaseFragment implements AdapterView.OnItemClickListener {
    private GridView gridview_type;
    private GuShiTypeAdapter guShiTypeAdapter;
    private List<GuShiTypeModel> guShiTypeList;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_gushi, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        gridview_type = (GridView) view.findViewById(R.id.gridview_type);

        loadDataToView();
    }

    private void loadDataToView() {
        guShiTypeList = new ArrayList<>();
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_thgs_pass,"童话故事","通过丰富的想象、幻想和夸张来塑造形象、反映生活。","http://www.61ertong.com/wenxue/tonghuagushi/list_177_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_sqgs_pass,"睡前故事","专门为哄孩子们睡觉准备的故事，把宝宝带进甜蜜的梦乡。","http://www.61ertong.com/wenxue/shuiqiangushi/list_178_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_yzgs_pass,"益智故事","汇集了古今中外智者的奇思妙想、机智灵活以及过人的胆识。","http://www.61ertong.com/wenxue/yizhigushi/list_179_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_mjgs_pass,"民间故事","在民间广泛流传而又充满幻想的叙事体故事。","http://www.61ertong.com/wenxue/minjiangushi/list_180_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_yygs_pass,"寓言故事","结构简短，含有讽喻或明显教训意义的故事。","http://www.61ertong.com/wenxue/yuyangushi/list_181_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_cygs_pass,"成语故事","每一个成语的背后都有一个含义深远的故事。","http://www.61ertong.com/wenxue/chengyugushi/list_182_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_glth_pass,"格林童话","德国民间文学，讲述了一个个神奇而又浪漫的童话故事。","http://www.61ertong.com/wenxue/gelintonghua/list_183_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_yqlyy_pass,"一千零一夜","著名的古代阿拉伯民间故事集，世界上最具生命力、最负盛名。","http://www.61ertong.com/wenxue/yiqianlingyiyegushi/list_184_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_zyjth_pass,"郑渊洁童话","郑渊洁笔下的童话，几乎伴随了中国一代人的成长。","http://www.61ertong.com/wenxue/zhengyuanjietonghua/list_185_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_atsth_pass,"安徒生童话","世界文学名著，全世界孩子最喜爱的安徒生童话。","http://www.61ertong.com/wenxue/antushengtonghua/list_186_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_xlsh_pass,"希腊神话","一切有关古希腊人的神、英雄、自然和宇宙历史的神话。","http://www.61ertong.com/wenxue/xilashenhua/list_187_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_mrgs_pass,"名人故事","他们有着精深的智慧，远大的抱负，无比坚强的毅力。","http://www.61ertong.com/wenxue/mingrengushi/list_188_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_aggs_pass,"爱国故事","从不同的角度讲述了一些爱国人物可歌可泣的爱国故事。","http://www.61ertong.com/wenxue/aiguogushi/list_189_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_cqgs_pass,"传奇故事","具有社会转型期特征的典型故事，且故事很精彩。","http://www.61ertong.com/wenxue/chuanqigushi/list_190_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_dwgs_pass,"帝王故事","历朝历代的帝目总是宏大历史的主角。","http://www.61ertong.com/wenxue/diwanggushi/list_191_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_dongwugs_pass,"动物故事","以动物为主人公的传说故事，形象各种被人格化了的动物。","http://www.61ertong.com/wenxue/dongwugushi/list_192_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_jxgs_pass,"惊险故事","从古至今，人世间不知发生了多少惊心动魄的故事...","http://www.61ertong.com/wenxue/jingxiangushi/list_193_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_zzgs_pass,"战争故事","讲述了各种战争故事，有牺牲、有大屠杀，有战壕里的战斗...","http://www.61ertong.com/wenxue/zhanzhenggushi/list_194_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_etxs_pass,"儿童小说","以儿童形象为中心的人物形象或以儿童视角所表现的故事。","http://www.61ertong.com/wenxue/ertongxiaoshuo/list_195_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_sxwqn_pass,"上下五千年","描述世界各国历来影响比较久远的事件和人物的故事。","http://www.61ertong.com/wenxue/shangxiawuqiannian/list_196_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_mjgs_pass,"少儿百科",".....","http://www.61ertong.com/wenxue/shaoerbaike/list_545_1.html"));
        guShiTypeList.add(new GuShiTypeModel(R.drawable.icon_type_zyjth_pass,"童话作文","......","http://www.61ertong.com/wenxue/tonghuazuowen/list_544_1.html"));

        guShiTypeAdapter = new GuShiTypeAdapter(guShiTypeList, GuShiTypeAdapter.ViewHolder.class);
        gridview_type.setAdapter(guShiTypeAdapter);
        gridview_type.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Intent intent = new Intent(context,ArticleListActivity.class);
        intent.putExtra(ArticleListActivity.INTENT_GUSHIMODEL_KEY,guShiTypeAdapter.getItem(position));
        startActivity(intent);
    }
}
